/**
 * 待办任务模块封装api接口
 */
import request from '@/utils/request'

// 获取分类列表
export const useGetClassificationsService = ({ user_id }) => {
  return request.get('/api/task/getclassifications', {
    params: {
      user_id: user_id
    }
  })
}

// 添加分类接口
export const useAddClassificationService = ({ classify_name, user_id }) => {
  return request.post('/api/task/addclassification', { classify_name, user_id })
}

// 删除分类接口
export const useDeleteClassificationService = ({ id }) => {
  return request.delete(`/api/task/deleteclassification/${id}`)
}

// 获取今日任务列表接口
export const useGetTodayTasksService = ({ user_id }) => {
  return request.get('/api/task/gettodaytasks', {
    params: {
      user_id: user_id
    }
  })
}

// 获取最近七日任务列表接口
export const useGetRecentSevenDaysTasksService = ({ user_id }) => {
  return request.get('/api/task/getrecentsevendaystasks', {
    params: {
      user_id: user_id
    }
  })
}

// 获取全部任务列表接口
export const useGetAllTasksService = ({ user_id }) => {
  return request.get('/api/task/getalltasks', {
    params: {
      user_id: user_id
    }
  })
}

// 获取分类任务列表接口
export const useGetTasksByClassificationService = ({ user_id, classify_id }) => {
  return request.get('/api/task/gettasksbyclassification', {
    params: {
      user_id: user_id,
      classify_id: classify_id
    }
  })
}

// 获取已完成任务列表接口
export const useGetFinishedTasksService = ({ user_id }) => {
  return request.get('/api/task/getfinishedtasks', {
    params: {
      user_id: user_id
    }
  })
}

// 获取已删除任务列表接口
export const useGetDeletedTasksService = ({ user_id }) => {
  return request.get('/api/task/getdeletedtasks', {
    params: {
      user_id: user_id
    }
  })
}

// 添加任务接口
export const useAddTaskService = ({ user_id, title, classify_id, classify_name, isFinished, finish_date, create_date, isDeleted }) => {
  return request.post('/api/task/addtask', { user_id, title, classify_id, classify_name, isFinished, finish_date, create_date, isDeleted })
}

// 编辑任务接口
export const useEditTaskService = ({ id, title, classify_id, classify_name, isFinished, finish_date }) => {
  return request.put(`/api/task/edittask/${id}`, { title, classify_id, classify_name, isFinished, finish_date })
}

// 完成任务接口
export const useFinishTaskService = ({ id }) => {
  return request.put(`/api/task/finishtask/${id}`)
}

// 删除任务接口(软删除)
export const useDeleteTaskService = ({ id }) => {
  return request.delete(`/api/task/deletetask/${id}`)
}

// 彻底删除任务接口
export const useDeleteTaskCompletelyService = ({ id }) => {
  return request.delete(`/api/task/deletetaskcompletely/${id}`)
}

// 彻底删除所有垃圾桶内任务接口
export const useDeleteAllSecondlyDeletedTasksService = ({ user_id }) => {
  return request.delete('/api/task/deleteallsecondlydeletedtasks', {
    params: {
      user_id: user_id
    }
  })
}

// 按月份获取任务列表接口
export const useGetTasksByMonthService = ({ user_id, month }) => {
  return request.get('/api/task/gettasksbymonth', {
    params: { user_id, month }
  })
}

